package com.cyq.day22.gobang;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;

public class Maple extends JFrame {
    private int x,y;
    BufferedImage image=null;
    @Override
    public void paint(Graphics g) {
        //双缓冲
        BufferedImage b=new BufferedImage(500,500,BufferedImage.TYPE_INT_RGB);
        Graphics g2=b.createGraphics();
        g2.setColor(Color.BLACK);
        g2.drawImage(image,0,20,this);
        g2.setFont(new Font("黑体",Font.BOLD,20));
        //g2.drawString("游戏信息"+message,130,60);
        for (int i = 0; i <19 ; i++) {
            g.drawLine(10,60+20*i,370,60+20*i);
            g.drawLine(10+20*i,60,10+20*i,420);
            //g.fillOval(183,183,4,4);
        }
        g.fillOval(x-4,y-4,8,8);
        repaint();
    }

    public Maple() {
        this.setTitle("五子棋");
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setBounds(200,100,500,500);
        this.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                x=e.getX();
                y=e.getY();
            }
        });
    }

    public static void main(String[] args) {
        Maple maple=new Maple();
        maple.setVisible(true);
        String s=new String();
    }
}
